import { Tabs, Form } from 'antd';
import { connect } from 'dva';
import ToDo from './todo'
import Hobby from './hobby'
import { userId } from '@/constant';
const { TabPane } = Tabs;
const creator = (type, payload) => ({ type, payload });

const Create = props => {
  function callback(key) {
    const { dispatch } = props;
    if (key === '1') {
      const id = window.sessionStorage.getItem(userId);
      dispatch(creator('hobby/query', id));
    }
  }

  return (
    <Tabs defaultActiveKey="1" onChange={callback}>
      <TabPane tab="计划" key="1">
        <ToDo />
      </TabPane>
      <TabPane tab="爱好" key="2">
        <Hobby />
      </TabPane>
    </Tabs>
  );
};

export default connect(({ title, paragraph }) => ({ title, paragraph }))(Create);
